﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class Lop_diadiemtiepnhan
    {
        string MDD,Tendiadiem,MloaiDD,Diachi,Toado,Nguoilienhe,Email,Miendiadiem;
        int SDT;
        public Lop_diadiemtiepnhan(){}
        public Lop_diadiemtiepnhan(string MDD,string Tendiadiem, string MloaiDD,string Diachi,string Toado,string Nguoilienhe,string Email,string Miendiadiem,int SDT)
        {
            this.MDD = MDD;
            this.Tendiadiem = Tendiadiem;
            this.MloaiDD = MloaiDD;
            this.Diachi = Diachi;
            this.Toado = Toado;
            this.Nguoilienhe = Nguoilienhe;
            this.Email = Email;
            this.Miendiadiem = Miendiadiem;
            this.SDT = SDT;
        }
        #region các thủ tục SET
        public void set_maDD(string MDD)
        {
            this.MDD = MDD;
        }
        public void set_Tendiadiem(string Tendiadiem)
        {
            this.Tendiadiem = Tendiadiem;
        }
        public void Set_MloaiDD(string MloaiDD)
        {
            this.MloaiDD = MloaiDD;
        }
        public void set_Diachi(string Diachi)
        {
            this.Diachi = Diachi;
        }
        public void set_Toado(string Toado)
        {
            this.Toado = Toado;
        }
        public void set_Nguoilienhe(string Nguoilienhe)
        {
            this.Nguoilienhe = Nguoilienhe;
        }
        public void st_Email(string Email)
        {
            this.Email = Email;
        }
        public void set_Miendiadiem(string Miendiadiem)
        {
            this.Miendiadiem = Miendiadiem;
        }
        public void set_SDT(int SDT)
        {
            this.SDT = SDT;
        }
        #endregion
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert into diadiem(MDD,Tendiadiem,MloaiDD,Diachi,Toado,Nguoilenhe,Email,Miendiadiem,SDT) values ('" + MDD + "',N'" + Tendiadiem + "','" + MloaiDD + "',N'" + Diachi + "'," + Toado + "',N'" + Nguoilienhe + "',N'" + Email + "',N'" + Miendiadiem + "','" + SDT + "')") == 1)
            {
               lop_ket_noi.huyketnoi();
               return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update diadiem set Tendiadiem = N'" + Tendiadiem + "',MloaiDD = '" + MloaiDD + "',Diachi = N'" + Diachi + "',Toado='" + Toado + "',Nguoilienhe='" + Nguoilienhe + "',Email='" + Email + "',Miendiadiem='" + Miendiadiem + "',SDT='" + SDT + "' where MDD='" + MDD + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from diadiem where MDD='" + MDD + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool tiepnhan()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if(dl.thucthitruyvan("update khachhang set TenKH = N'"+ Tendiadiem + "', SDD = '"+ SDT +"',LoaiDD= '"+ MloaiDD+ "' where MDD='" + MDD + "'")==1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
